import { CellValue } from "hyperformula";
import { IService } from "./IService";

/**
 * 用户了解的关键概念：
 * 公式字符串
 * 变量
 */
export interface IFormulaService extends IService {
  calculate(formula: string): CellValue;
  listFunctionNames(): string[];
  getFunctionHelp(functionName: string): string;
  /**
   * 在sheet1 rowN col1+ 处设置变量
   * col1 Number A numeric value such as 0, 2, -40, 0.1, and also scientific notation e.g. 5.6E+01; with a period as a default decimal separator.
   * col2 Text A text value, like "ABC", "apollo".
   * col3 Logical A logical value might be one of two values: TRUE or FALSE. Please note that even if there is type coercion this will be recognized as TRUE/FALSE when comparing to numbers. It will not be recognized as 1 or 0.
   * col4 Date A Gregorian calendar date in DD/MM/YYYY (default format), like 22/06/2022. All dates from 30/12/1899 to 31/12/9999 are supported.
   * col5 Time A time in hh:mm:ss or hh:mm (default format), like 10:40:16.
   * col6 DateTime Date and Time types combined into one, like 22/06/2022 10:40:16.
   * col7 Error An error returned as a result of formula calculation, like #REF!
   * col8 Duration	A time-based amount of time
   * col9 Currency	Number representing currency
   * col10 Percentage	Number representing percentage
   * @param _value
   * @param _valueType
   */
  setVariable(value: any, valueType: ValueType): string | undefined;
  getVariable(name: string): CellValue;
}

/**
 * 一方面是值类型，另一方面是存放的位置col index
 */
export enum ValueType {
  Number = 1,
  Text = 2,
  Logical = 3,
  Date = 4,
  Time = 5,
  DateTime = 6,
  Error = 7,
  Duration = 8,
  Currency = 9,
  Percentage = 10,

  Matrix = 50, // 矩阵数据，占用右侧好几列
}
